#include "Window.hpp"

using namespace luabind;
namespace bind
{
	namespace SL
	{
		namespace window
		{
			void BWindowSettings(lua_State* lua, const std::string& ns)
			{
				module(lua, ns.c_str())
					[
						class_<sl::WindowSettings>("WindowSettings")
							.def(constructor<>())
							.def(constructor<sf::VideoMode, const std::string&, char, const sf::ContextSettings&>())
							.def("Create", &sl::WindowSettings::Create)
							.def("GetMode", &sl::WindowSettings::GetMode)
							.def("SetMode", &sl::WindowSettings::SetMode)
							.def("GetStyle", &sl::WindowSettings::GetStyle)
							.def("SetStyle", &sl::WindowSettings::SetStyle)
							.def("GetSettings", &sl::WindowSettings::GetSettings)
							.def("SetSettings", &sl::WindowSettings::SetSettings)
							.def("GetCaption", &sl::WindowSettings::GetCaption)
							.def("SetCaption", &sl::WindowSettings::SetCaption)
							.def("GetFullscreen", &sl::WindowSettings::GetFullscreen)
							.def("SetFullscreen", &sl::WindowSettings::SetFullscreen)
							.def("LoadFromFile", &sl::WindowSettings::LoadFromFile)
							.def("SaveToFile", (sl::WindowSettings*(sl::WindowSettings::*)(const std::string&))&sl::WindowSettings::SaveToFile)
							.def("SaveToFile", (sl::WindowSettings*(sl::WindowSettings::*)(pugi::xml_node*, const std::string&))&sl::WindowSettings::SaveToFile)
							/*.def(other<std::ostream>() + const_self)
							.def(other<std::istream>() - self)*/
					];
			}

			void BZoomable(lua_State* lua, const std::string& ns)
			{
				//////////////////// MIST
				module(lua, ns.c_str())
					[
						class_<sl::Zoomable>("Zoomable")
							.def(constructor<float>())
							/*.def("SetZoomLevel", &sl::Zoomable::SetZoomLevel)
							.def("GetZoomLevel", &sl::Zoomable::GetZoomLevel)
							.def("AddZoomLevel", &sl::Zoomable::AddZoomLevel)
							.def("ResetZoom", &sl::Zoomable::ResetZoom)*/
					];
			}

			void BRenderScreen(lua_State* lua, const std::string& ns)
			{
				module(lua, ns.c_str())
					[
						class_<sl::tmp::RenderScreenS, bases<sl::WindowSettings, sl::Zoomable> >("RenderScreen")
							.def(constructor<>())
							.def("Open", &sl::tmp::RenderScreenS::Open)
							.def("GetWindow", &sl::tmp::RenderScreenS::GetWindow)
					];

				globals(lua)[ns.c_str()]["RenderScreen"] = sl::RenderScreen;
			}

			void Bind(lua_State* lua, const std::string& ns)
			{
				open(lua);
				BWindowSettings(lua, ns);
				BZoomable(lua, ns);
				BRenderScreen(lua, ns);
			}
		}
	}
}